package com.cnpc.ds.controller;

import org.springframework.web.bind.annotation.*;
import com.cnpc.ds.service.IOmsSysUserService;
import com.cnpc.ds.entity.OmsSysUser;
import com.cnpc.eisc.base.pojo.PageInfo;
import com.cnpc.eisc.base.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
* 演示测试用例
* @author 作者
* @since 2024-10-15
*/
@RestController
@Slf4j
@RequestMapping("/main/oms-sys-user")
    public class OmsSysUserController {

    @Autowired
    private IOmsSysUserService omsSysUserService;

    /**
    * 用户表_列表
    * @param pageNum 第几页，从0开始 默认0
    * @param pageSize 每页条数 默认10条
    * @param sortField 排序字段 数据库字段 默认create_time
    * @param isAsc 是否正序 默认false
    * @param omsSysUser 搜索
    */
    @GetMapping(value="/page")
    public Result<PageInfo<OmsSysUser>> queryPage(@RequestParam(required = false, defaultValue = "0") Integer pageNum,
                                        @RequestParam(required = false, defaultValue = "10") Integer pageSize,
                                        @RequestParam(required = false, defaultValue = "CREATE_DATE") String sortField,
                                        @RequestParam(required = false, defaultValue = "false") Boolean isAsc,
                                        OmsSysUser omsSysUser){
        log.info("查询用户表列表入参，页码：{},每页条数：{},搜索参数{}", pageNum,pageSize,omsSysUser);
        PageInfo<OmsSysUser> pageInfo=new PageInfo();
        pageInfo.setPageSize(pageSize);
        pageInfo.setPageNum(pageNum);
        return Result.ok(omsSysUserService.query(pageInfo,sortField,isAsc,omsSysUser));
    }

    /**
    * 用户表_新增 或者 修改
    * @param omsSysUser
    */
    @PostMapping(value="/add")
    public Result<Integer> add(@RequestBody OmsSysUser omsSysUser){
        log.info("新增用户表入参：{}", omsSysUser);
        return Result.ok(omsSysUserService.add(omsSysUser));
    }

    /**
    * 用户表_批量删除
    * @param ids 主键id组
    */
    @PostMapping(value="/delete")
    public Result<Integer> delete(@RequestBody List<String> ids){
        log.info("删除用户表入参，主键ID组：{}", ids);
        return Result.ok(omsSysUserService.delete(ids));
    }

     /**
     * 用户表_详情
     * @param id 主键ID
     */
     @GetMapping("/detail")
     public Result<OmsSysUser> detail(@RequestParam("id") String id){
        log.info("查询用户表详情入参，主键ID:{}", id);
        return Result.ok(omsSysUserService.detail(id));
     }
}
